package zozopo.manual;

import java.sql.Connection;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;

import zozopo.database.BusiDatabaseManager;
import zozopo.operations.comm.DictionaryOS;
import zozopo.operations.comm.DictionaryTB;
import zozopo.user.operations.UserTB;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class PreRecommendAction extends ActionSupport implements Action ,SessionAware,ServletRequestAware{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	List<DictionaryTB> dictionaryLableList;
	public List<DictionaryTB> getDictionaryLableList() {
		return dictionaryLableList;
	}

	public void setDictionaryLableList(List<DictionaryTB> dictionaryLableList) {
		this.dictionaryLableList = dictionaryLableList;
	}
	HttpServletRequest request;
	private Map<Object, Object> session;

	
	public String execute(){
		
		
		UserTB user = (UserTB) session.get("userInfo");
		
		if(user == null){
			return NONE;
		}
		
		Character limitflag4 = user.getUser_limitflag().charAt(4);
		Integer intLimitflag4 = Integer.parseInt(limitflag4.toString());
		
		if(intLimitflag4 <=0){
			return NONE;
		}
		BusiDatabaseManager databaseConnection = new BusiDatabaseManager();
		Connection conn = databaseConnection.getConnection();
		
		DictionaryOS dictionaryOS = new DictionaryOS(conn);
		
		dictionaryLableList = dictionaryOS.getDictionaryLableList();
		
		databaseConnection.releaseConnection(conn);
		
		return SUCCESS;
	}
	
	public void setSession(Map arg0) {
		// TODO Auto-generated method stub
		session = arg0;
	}
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		request = arg0;
		
	}
}
